$(document).on('pageinit', function(){

    $('#create_group_form').validate({
        rules: {
            carpool_name: {
                required: true,
                maxlength: 40
            }
        },
        messages: {
            carpool_name: {
                required: "Enter a name for the group.",
                maxlength: "Can't be longer then 40 characters."
            }
        },
        errorPlacement: function (error, element) {
            if (element.is("input") && !element.is('input[type="hidden"]'))
                error.insertAfter(element.parent());
            else
                error.insertAfter(element);
        }
    });

});